package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConst;
import com.itheima.entity.Result;
import com.itheima.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author TonyHao
 * @version v 1.0
 * @description
 * @data 2020/3/4
 */

/**
 * @RestController   相当于ResponseBody + @Controller
 *
 *
 *
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Reference
    private UserService userService;

    @RequestMapping("/login")
    @ResponseBody
    public Result login(String username, String password){

        if(userService.login(username,password)){
            log.debug("login ok!!!");
            return new Result(true, MessageConst.ACTION_SUCCESS);
        }else{
            log.debug("login fail");
            return new Result(false,MessageConst.ACTION_FAIL);
        }
    }
}
